package top.xana.acg.anime.inject

import android.app.Application
import androidx.room.Room
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import top.xana.acg.anime.config.ANIME_DATABASE
import top.xana.acg.anime.database.AnimeDao
import top.xana.acg.anime.database.AnimeDatabase
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object DatabaseModule {

    @Provides
    @Singleton
    fun provideAppDatabase(
        application: Application,
//    typeResponseConverter: TypeResponseConverter
    ): AnimeDatabase {
        return Room
            .databaseBuilder(application, AnimeDatabase::class.java, ANIME_DATABASE)
            .fallbackToDestructiveMigration()
//      .addTypeConverter(typeResponseConverter)
            .build()
    }

    @Provides
    @Singleton
    fun provideMusicDao(appDatabase: AnimeDatabase): AnimeDao {
        return appDatabase.animeDao()
    }

}
